package com.maoyanjava.controller;

import com.alibaba.fastjson.JSON;
import com.maoyanjava.pojo.User;
import com.maoyanjava.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;



@RestController
public class UserController {
    @Autowired
    private UserService us;
    @GetMapping("/login")
    public void login(HttpServletRequest request, HttpServletResponse response){
        String uname = request.getParameter("username");
        String pwd = request.getParameter("pwd");
        User u = us.gatOne(uname,pwd);

        String s = JSON.toJSONString(u);
        try {
            response.getWriter().print(s);
        } catch (IOException exception) {
            exception.printStackTrace();
        }
    }
}
